/**
 * 
 */
package com.google.code.cisx.client.login.service;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * Login service to perform user authentication.
 * 
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @since 1.0
 * @version $Id: LoginService.java 258 2008-11-29 06:23:51Z rahul.thakur.xdev $
 */
public interface LoginService extends RemoteService {

  /**
   * Attempts to login a user with the specified username and password.
   * 
   * @param username
   * @param password
   * @return authentication token as {@link String} if the login was successful,
   *         else <code>null</code>.
   */
  public String login(String username, String password);

  public static class Util {

    private static LoginServiceAsync asyncInstance;

    public static LoginServiceAsync getAsyncInstance() {
      if (null == asyncInstance) {
        asyncInstance = (LoginServiceAsync) GWT.create(LoginService.class);
        // TODO: Set up other properties for the Async service instance
        // before returning to browser client.

        ((ServiceDefTarget) asyncInstance).setServiceEntryPoint(GWT.getModuleBaseURL()
            + "login/LoginService");

      }
      return asyncInstance;
    }
  }

}
